import { createRouter, createWebHashHistory } from "vue-router"
import store from '../store'
// 2. 定义一些路由
// 每个路由都需要映射到一个组件。
// 我们后面再讨论嵌套路由。
const routes = [
  { 	  
	  path: '/', 
	  meta:{"auth":true,"name":"首页"},
	  component: () => import('../views/layout/index.vue'),
	  children:[
		   {
		  	path: '/',
		  	name: '/',
		  	meta:{"auth":true,"name":"首页"},
		  	component: () => import('../views/home/index.vue'),
		   },
	  	   {
	  			path: '/basic/employees/cate',
	  			name: '/basic/employees/cate',
	  			meta:{"auth":true,"name":"人员分类"},
	  			component: () => import('../views/basic/employees/cate.vue'),
	  	   },
		   {
				path: '/basic/employees/person',
				name: '/basic/employees/person',
				meta:{"auth":true,"name":"人员档案"},
				component: () => import('../views/basic/employees/person.vue'),
		   },
		   {
				path: '/custom/cate',
				name: '/custom/cate',
				meta:{"auth":true,"name":"客户分类"},
				component: () => import('../views/custom/cate.vue'),
		   },
		   {
				path: '/custom/index',
				name: '/custom/index',
				meta:{"auth":true,"name":"客户联系人"},
				component: () => import('../views/custom/index.vue'),
		   },
		   {
				path: '/custom/vip',
				name: '/custom/vip',
				meta:{"auth":true,"name":"正式客户"},
				component: () => import('../views/custom/vip.vue'),
		   },
		   {
				path: '/custom/dispatch',
				name: '/custom/dispatch',
				meta:{"auth":true,"name":"客户分派"},
				component: () => import('../views/custom/dispatch.vue'),
		   },
		   {
				path: '/custom/stop',
				name: '/custom/stop',
				meta:{"auth":true,"name":"客户终止申请"},
				component: () => import('../views/custom/stop.vue'),
		   },
		   {
				path: '/custom/change',
				name: '/custom/change',
				meta:{"auth":true,"name":"客户变更申请"},
				component: () => import('../views/custom/change.vue'),
		   },
		   {
				path: '/tax/tax-personnel',
				name: '/tax/tax-personnel',
				meta:{"auth":true,"name":"个税人员信息"},
				component: () => import('../views/tax/taxPersonnel.vue'),
		   },
		   {
				path: '/tax/task-center',
				name: '/tax/task-center',
				meta:{"auth":true,"name":"任务中心"},
				component: () => import('../views/tax/taskCenter.vue'),
		   },
		   {
				path: '/tax/payroll',
				name: '/tax/payroll',
				meta:{"auth":true,"name":"工资表"},
				component: () => import('../views/tax/payroll.vue'),
		   },
		   {
				path: '/tax/tax-entry',
				name: '/tax/tax-entry',
				meta:{"auth":true,"name":"税费录入"},
				component: () => import('../views/tax/taxEntry.vue'),
		   },
		   {
				path: '/tax/tax-withholding',
				name: '/tax/tax-withholding',
				meta:{"auth":true,"name":"纳税申报"},
				component: () => import('../views/tax/taxWithholding.vue'),
		   },
		   {
				path: '/tax/tax-return',
				name: '/tax/tax-return',
				meta:{"auth":true,"name":"纳税扣缴"},
				component: () => import('../views/tax/taxReturn.vue'),
		   },
		   {
				path: '/paper/company/place-order',
				name: '/paper/company/place-order',
				meta:{"auth":true,"name":"下单管理"},
				component: () => import('../views/paper/company/placeOrder.vue'),
		   },
		   {
				path: '/paper/company/address',
				name: '/paper/company/address',
				meta:{"auth":true,"name":"地址管理"},
				component: () => import('../views/paper/company/address.vue'),
		   },
		   {
				path: '/paper/company/sendreceive/paper-delivery',
				name: '/paper/company/sendreceive/paper-delivery',
				meta:{"auth":true,"name":"票据发运"},
				component: () => import('../views/paper/company/sendReceive/paperDelivery.vue'),
		   },
		   {
				path: '/paper/company/sendreceive/to-sign-scan',
				name: '/paper/company/sendreceive/to-sign-scan',
				meta:{"auth":true,"name":"凭证签收(扫)"},
				component: () => import('../views/paper/company/sendReceive/toSignScan.vue'),
		   },
		   {
				path: '/paper/company/sendreceive/to-sign',
				name: '/paper/company/sendreceive/to-sign',
				meta:{"auth":true,"name":"凭证签收"},
				component: () => import('../views/paper/company/sendReceive/toSign.vue'),
		   },
		   {
				path: '/paper/company/sendreceive/detailedquery/paper-subsidiary',
				name: '/paper/company/sendreceive/detailedquery/paper-subsidiary',
				meta:{"auth":true,"name":"票据明细"},
				component: () => import('../views/paper/company/sendReceive/detailedQuery/paperSubsidiary.vue'),
		   },
		   {
				path: '/paper/company/sendreceive/detailedquery/book-details',
				name: '/paper/company/sendreceive/detailedquery/book-details',
				meta:{"auth":true,"name":"账本明细"},
				component: () => import('../views/paper/company/sendReceive/detailedQuery/bookDetails.vue'),
		   },
		   {
				path: '/paper/company/sendreceive/detailedquery/customer-paper-delivery',
				name: '/paper/company/sendreceive/detailedquery/customer-paper-delivery',
				meta:{"auth":true,"name":"客户凭证发运"},
				component: () => import('../views/paper/company/sendReceive/customerBill/customerPaperDelivery.vue'),
		   },
		   {
				path: '/paper/company/sendreceive/customerbill/bill-to-sign',
				name: '/paper/company/sendreceive/customerbill/bill-to-sign',
				meta:{"auth":true,"name":"客户票据签收"},
				component: () => import('../views/paper/company/sendReceive/customerBill/billToSign.vue'),
		   },
		   {
				path: '/paper/company/returnedmanagement/whose-ticket-abnormal',
				name: '/paper/company/returnedmanagement/whose-ticket-abnormal',
				meta:{"auth":true,"name":"审票异常"},
				component: () => import('../views/paper/company/returnedManagement/whoseTicketAbnormal.vue'),
		   },
		   {
				path: '/paper/company/returnedmanagement/voucher-input-abnormal',
				name: '/paper/company/returnedmanagement/voucher-input-abnormal',
				meta:{"auth":true,"name":"凭证录入异常"},
				component: () => import('../views/paper/company/returnedManagement/voucherInputAbnormal.vue'),
		   },
		   {
				path: '/paper/company/returnedmanagement/credentials-review-abnormal',
				name: '/paper/company/returnedmanagement/credentials-review-abnormal',
				meta:{"auth":true,"name":"凭证审核异常"},
				component: () => import('../views/paper/company/returnedManagement/credentialsReviewAbnormal.vue'),
		   },
		   {
				path: '/smart/paper-upload',
				name: '/smart/paper-upload',
				meta:{"auth":true,"name":"票据上传"},
				component: () => import('../views/smart/paperUpload.vue'),
		   },
		   {
				path: '/smart/paper-dispatch',
				name: '/smart/paper-dispatch',
				meta:{"auth":true,"name":"票据分派"},
				component: () => import('../views/smart/paperDispatch.vue'),
		   },
		   {
				path: '/smart/principle-ticket',
				name: '/smart/principle-ticket',
				meta:{"auth":true,"name":"智能理票"},
				component: () => import('../views/smart/principleTicket.vue'),
		   },
		   {
				path: '/smart/charge-account',
				name: '/smart/charge-account',
				meta:{"auth":true,"name":"智能记账"},
				component: () => import('../views/smart/chargeAccount.vue'),
		   },
		   {
				path: '/app/vip/accounts',
				name: '/app/vip/accounts',
				meta:{"auth":true,"name":"客户企业套账"},
				component: () => import('../views/app/vip/accounts.vue'),
		   },
		   {
				path: '/app/service/message',
				name: '/app/service/message',
				meta:{"auth":true,"name":"反馈管理"},
				component: () => import('../views/app/service/message.vue'),
		   },
		   {
				path: '/app/dozhang/net-data',
				name: '/app/dozhang/net-data',
				meta:{"auth":true,"name":"进销数据"},
				component: () => import('../views/app/dozhang/netData.vue'),
		   },
		   {
				path: '/app/dozhang/other-fees',
				name: '/app/dozhang/other-fees',
				meta:{"auth":true,"name":"其他费用"},
				component: () => import('../views/app/dozhang/otherFees.vue'),
		   },
		   {
				path: '/app/dozhang/bank-receipt',
				name: '/app/dozhang/bank-receipt',
				meta:{"auth":true,"name":"银行回单及流水"},
				component: () => import('../views/app/dozhang/bankReceipt.vue'),
		   },
		   {
				path: '/app/dozhang/payroll',
				name: '/app/dozhang/payroll',
				meta:{"auth":true,"name":"工资表"},
				component: () => import('../views/app/dozhang/payroll.vue'),
		   },
		   {
				path: '/app/declaredutiablegoods/individual-income-tax',
				name: '/app/declaredutiablegoods/individual-income-tax',
				meta:{"auth":true,"name":"个人所得税"},
				component: () => import('../views/app/declaredutiablegoods/individualIncomeTax.vue'),
		   },
		   {
				path: '/app/declaredutiablegoods/tax-return',
				name: '/app/declaredutiablegoods/tax-return',
				meta:{"auth":true,"name":"纳税申报"},
				component: () => import('../views/app/declaredutiablegoods/taxReturn.vue'),
		   },
		   {
				path: '/app/declaredutiablegoods/paying-taxes',
				name: '/app/declaredutiablegoods/paying-taxes',
				meta:{"auth":true,"name":"税款缴纳"},
				component: () => import('../views/app/declaredutiablegoods/payingTaxes.vue'),
		   },
		   {
				path: '/app/taxdata/file',
				name: '/app/taxdata/file',
				meta:{"auth":true,"name":"财务数据附件"},
				component: () => import('../views/app/taxdata/file.vue'),
		   },
		   {
				path: '/app/bigdata/schedule-of',
				name: '/app/bigdata/schedule-of',
				meta:{"auth":true,"name":"共享中心财务业务执行明细表"},
				component: () => import('../views/bigdata/scheduleOf.vue'),
		   },
		   {
				path: '/app/bigdata/smart-schedule-of',
				name: '/app/bigdata/smart-schedule-of',
				meta:{"auth":true,"name":"智能核算明细表"},
				component: () => import('../views/bigdata/smartScheduleOf.vue'),
		   },
	  ]
  },
]

// 3. 创建路由实例并传递 `routes` 配置
// 你可以在这里输入更多的配置，但我们在这里
// 暂时保持简单
const router = createRouter({
  // 4. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
  history: createWebHashHistory(),
  routes, // `routes: routes` 的缩写
})
//路由前置守卫
router.beforeEach((to, from, next) => {	
  if(to.meta.auth){	
	//是否登录
	let isLogin = true;
	if(store.state.isLogin == true) isLogin = true;
	if(!isLogin){
		next({ name: 'Login' })
	}else{
		next()  
	}		
  }else{
	  next()
  }
  
})

export default router